import React from "react";
import { Avatar } from "antd";
import { UserOutlined, TagOutlined, TeamOutlined } from "@ant-design/icons";
import { OptionData } from "../../components/SearchTagSelect";

/**
 * 模拟用户数据
 */
export const mockUsers: OptionData[] = [
  {
    value: "user1",
    label: "张三",
    icon: (
      <Avatar size="small" style={{ backgroundColor: "#1677ff" }}>
        张
      </Avatar>
    ),
    data: { department: "技术部" },
  },
  {
    value: "user2",
    label: "李四",
    icon: (
      <Avatar size="small" style={{ backgroundColor: "#52c41a" }}>
        李
      </Avatar>
    ),
    data: { department: "技术部" },
  },
  {
    value: "user3",
    label: "王五",
    icon: (
      <Avatar size="small" style={{ backgroundColor: "#faad14" }}>
        王
      </Avatar>
    ),
    data: { department: "产品部" },
  },
  {
    value: "user4",
    label: "赵六",
    icon: (
      <Avatar size="small" style={{ backgroundColor: "#eb2f96" }}>
        赵
      </Avatar>
    ),
    data: { department: "产品部" },
  },
];

/**
 * 模拟标签数据
 */
export const mockTags: OptionData[] = [
  { value: "tag1", label: "前端开发", icon: <TagOutlined />, color: "blue" },
  { value: "tag2", label: "后端开发", icon: <TagOutlined />, color: "green" },
  { value: "tag3", label: "UI设计", icon: <TagOutlined />, color: "purple" },
  { value: "tag4", label: "产品设计", icon: <TagOutlined />, color: "magenta" },
];

/**
 * 模拟部门数据
 */
export const mockDepartments: OptionData[] = [
  {
    value: "dept1",
    label: "技术部",
    icon: <TeamOutlined />,
    color: "processing",
  },
  { value: "dept2", label: "产品部", icon: <TeamOutlined />, color: "success" },
];

/**
 * 合并所有选项的基础数据
 */
export const allOptions = [...mockUsers, ...mockTags, ...mockDepartments];

/**
 * 生成更多的模拟用户数据
 */
export const generateMoreUsers = (
  count: number,
  startIndex = 0
): OptionData[] => {
  const colors = [
    "#1677ff",
    "#52c41a",
    "#faad14",
    "#eb2f96",
    "#722ed1",
    "#13c2c2",
    "#fa541c",
  ];
  const departments = [
    "技术部",
    "产品部",
    "设计部",
    "市场部",
    "销售部",
    "运维部",
    "财务部",
  ];
  const names = [
    "张",
    "李",
    "王",
    "赵",
    "钱",
    "孙",
    "周",
    "吴",
    "郑",
    "冯",
    "陈",
    "楚",
    "魏",
    "蒋",
    "沈",
  ];

  return Array.from({ length: count }, (_, i) => {
    const index = startIndex + i;
    const nameChar = names[index % names.length];
    const colorIndex = index % colors.length;
    const deptIndex = index % departments.length;

    return {
      value: `user${index + 100}`,
      label: `伪${nameChar}${index + 100}`,
      icon: (
        <Avatar size="small" style={{ backgroundColor: colors[colorIndex] }}>
          {nameChar}
        </Avatar>
      ),
      data: { department: departments[deptIndex] },
    };
  });
};

/**
 * 生成更多的模拟标签数据
 */
export const generateMoreTags = (count: number): OptionData[] => {
  const topics = [
    "API开发",
    "自动化测试",
    "微服务",
    "持续集成",
    "代码优化",
    "数据分析",
    "UI组件",
    "性能优化",
    "安全测试",
    "文档编写",
    "前端框架",
    "后端架构",
    "可视化",
    "移动开发",
    "桌面应用",
  ];
  const colors = [
    "blue",
    "green",
    "orange",
    "purple",
    "cyan",
    "magenta",
    "lime",
  ];

  return Array.from({ length: count }, (_, i) => ({
    value: `tag${i + 10}`,
    label: topics[i % topics.length],
    icon: <TagOutlined />,
    color: colors[i % colors.length],
  }));
};

/**
 * 扩展的模拟数据集合，用于分页示例
 */
export const extendedMockData = {
  users: [...mockUsers, ...generateMoreUsers(50)],
  tags: [...mockTags, ...generateMoreTags(30)],
  departments: mockDepartments,
  all: [
    ...mockUsers,
    ...mockTags,
    ...mockDepartments,
    ...generateMoreUsers(50),
    ...generateMoreTags(30),
  ],
};

export default {
  users: mockUsers,
  tags: mockTags,
  departments: mockDepartments,
  allOptions,
  generateMoreUsers,
  generateMoreTags,
  extendedMockData,
};
